using UnityEngine;
using Voodoo.Pattern;

public class Missile : MonoBehaviour
{
	public float Speed;

	public float DropRate;

	public Rigidbody thisRigid;

	public GameObject ExplosionEffect;

	private void Start()
	{
		Object.Destroy(base.gameObject, 5f);
	}

	private void FixedUpdate()
	{
		thisRigid.MovePosition(base.transform.position + base.transform.right * Speed * Time.fixedDeltaTime);
		base.transform.Rotate(new Vector3(0f, 0f, DropRate * Time.fixedDeltaTime), Space.Self);
	}

	private void OnTriggerEnter(Collider other)
	{
		if (other.CompareTag("Finish"))
		{
			Explode();
		}
	}

	private void Explode()
	{
		GameObject obj = Object.Instantiate(ExplosionEffect);
		obj.transform.position = base.transform.position;
		Object.Destroy(obj.gameObject, 3f);
		Collider[] array = Physics.OverlapSphere(base.transform.position, 1.2f);
		foreach (Collider collider in array)
		{
			if (collider.CompareTag("Finish"))
			{
				Head.AddPhysics(collider);
				SingletonMB<Progress>.Instance.KillBlock();
			}
		}
		SingletonMB<GameManager>.Instance.GameplayHaptic.PlayHaptic(HapticType.Big);
		Object.Destroy(base.gameObject);
	}
}
